﻿<UserControl x:Class="QSHC.QSchedule.Silverlight.Views.UserControls.AppointmentList"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:custom="clr-namespace:QSHC.CustomControl;assembly=QSHC.CustomControl"
    xmlns:vm="clr-namespace:QSHC.QSchedule.Silverlight.ViewModels"
    xmlns:converter="clr-namespace:QSHC.QSchedule.Silverlight.Converters"
    xmlns:dataPrimitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Data"
    mc:Ignorable="d" FontFamily="Tahoma" FontSize="14" Language="th-TH"
    d:DesignHeight="400" d:DesignWidth="850" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">
    
    <UserControl.Resources>
  
        <converter:PhysicianToTextConverter x:Key="physicianToTextConverter" />
        <Style x:Key="DataGridColumnHeaderStyle" TargetType="dataPrimitives:DataGridColumnHeader">
            <Setter Property="Foreground" Value="#FF000000"/>
            <Setter Property="HorizontalContentAlignment" Value="Left"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="IsTabStop" Value="False"/>
            <Setter Property="SeparatorBrush" Value="#FFC9CACA"/>
            <Setter Property="Padding" Value="4"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="dataPrimitives:DataGridColumnHeader">
                        <Grid x:Name="Root">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal"/>
                                    <VisualState x:Name="MouseOver">
                                        <Storyboard>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundRectangle" Storyboard.TargetProperty="(Fill).Color" To="#FF448DCA"/>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Fill).(GradientStops)[3].Color" To="#7FFFFFFF"/>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Fill).(GradientStops)[2].Color" To="#CCFFFFFF"/>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Fill).(GradientStops)[1].Color" To="#F2FFFFFF"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Pressed">
                                        <Storyboard>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundRectangle" Storyboard.TargetProperty="(Fill).Color" To="#FF448DCA"/>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Fill).(GradientStops)[0].Color" To="#D8FFFFFF"/>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Fill).(GradientStops)[1].Color" To="#C6FFFFFF"/>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Fill).(GradientStops)[2].Color" To="#8CFFFFFF"/>
                                            <ColorAnimation Duration="0" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Fill).(GradientStops)[3].Color" To="#3FFFFFFF"/>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="SortStates">
                                    <VisualState x:Name="Unsorted"/>
                                    <VisualState x:Name="SortAscending"/>
                                    <VisualState x:Name="SortDescending"/>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Rectangle x:Name="BackgroundRectangle" Fill="#FF1F3B53" Stretch="Fill" Grid.ColumnSpan="2"/>
                            <Rectangle x:Name="BackgroundGradient" Stretch="Fill" Grid.ColumnSpan="2">
                                <Rectangle.Fill>
                                    <LinearGradientBrush EndPoint=".7,1" StartPoint=".7,0">
                                        <GradientStop Color="#FCFFFFFF" Offset="0.015"/>
                                        <GradientStop Color="#F7FFFFFF" Offset="0.375"/>
                                        <GradientStop Color="#E5FFFFFF" Offset="0.6"/>
                                        <GradientStop Color="#D1FFFFFF" Offset="1"/>
                                    </LinearGradientBrush>
                                </Rectangle.Fill>
                            </Rectangle>
                            <Rectangle x:Name="verticalSeparator" Fill="{TemplateBinding SeparatorBrush}" VerticalAlignment="Stretch" Width="1" Visibility="{TemplateBinding SeparatorVisibility}" Grid.Column="1"/>
                            <CheckBox x:Name="SelectedAllCheckBox" Content=""  VerticalAlignment="Center" HorizontalAlignment="Center" Loaded="SelectedAllCheckBox_Loaded" Click="SelectedAllCheckBox_Click" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    
    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.RowDefinitions>
            <RowDefinition Height="320" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <sdk:DataGrid AutoGenerateColumns="False" IsReadOnly="True" Name="ScheduleDataGrid" ItemsSource="{Binding Path=Appointments}">
            <sdk:DataGrid.Columns>
                <sdk:DataGridTemplateColumn HeaderStyle="{StaticResource DataGridColumnHeaderStyle}" Width="30">
                    <sdk:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox HorizontalAlignment="Center" IsChecked="{Binding Path=IsSelected, Mode=TwoWay}" Name="SelectedCheckBox" VerticalAlignment="Center" />
                        </DataTemplate>
                    </sdk:DataGridTemplateColumn.CellTemplate>
                </sdk:DataGridTemplateColumn>
                <sdk:DataGridTextColumn Binding="{Binding HN}" Header="HN" />
                <sdk:DataGridTemplateColumn Header="ชื่อ-สกุล">
                    <sdk:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                                <TextBlock Margin="4,0,0,0" Text="{Binding AppointedPatient.Title}" />
                                <TextBlock Text="{Binding AppointedPatient.FirstName}" />
                                <TextBlock Text="  " />
                                <TextBlock Margin="0,0,4,0" Text="{Binding AppointedPatient.LastName}" />
                            </StackPanel>
                        </DataTemplate>
                    </sdk:DataGridTemplateColumn.CellTemplate>
                </sdk:DataGridTemplateColumn>
                <sdk:DataGridTextColumn Binding="{Binding Path=AppointmentDate, StringFormat=\{0:D\}}" Header="วันที่นัด" />
                <sdk:DataGridTextColumn Binding="{Binding Path=Service.Name}" Header="หน่วยบริการ" />
                <sdk:DataGridTextColumn Binding="{Binding Converter={StaticResource physicianToTextConverter}, Path=Physician, ConverterParameter=short}" Header="แพทย์" />
                <sdk:DataGridTextColumn Binding="{Binding Path=AppointedPatient.Payor}" Header="สิทธิ" />
                <sdk:DataGridTemplateColumn Header="เคยเลื่อนนัด">
                    <sdk:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Postpone}" TextAlignment="Center" VerticalAlignment="Center" />
                        </DataTemplate>
                    </sdk:DataGridTemplateColumn.CellTemplate>
                </sdk:DataGridTemplateColumn>
            </sdk:DataGrid.Columns>
        </sdk:DataGrid>
        <StackPanel Grid.Row="1">
            <StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
                <TextBlock Text="หน่วยบริการ:" Style="{StaticResource TextBlockStyle}" Margin="5,0,0,0" />
                <ComboBox Width="150" Margin="5,0,0,0" ItemsSource="{Binding Path=Services}" DisplayMemberPath="Name" SelectedItem="{Binding Path=SelectedPostponeService, Mode=TwoWay}" Style="{StaticResource ComboBoxStyle}" Name="PostponeLocationComboBox" />

                <TextBlock Text="แพทย์:" Style="{StaticResource TextBlockStyle}" Margin="10,0,0,0" />
                <custom:AutoCompleteComboBox x:Name="PostponePhysicianACCB" 
                                                     ItemsSource="{Binding Path=PostponePhysicians}" Width="200" 
                                                     MaxDropDownHeight="200" 
                                                     Margin="5" Height="25" FontFamily="Tahoma" FontSize="14" SelectedItem="{Binding Path=SelectedPostponePhysician, Mode=TwoWay}" Text="{Binding Path=SelectedPostponePhysicianText, Mode=TwoWay}">
                    <custom:AutoCompleteComboBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <TextBlock Text="{Binding EmployeeCode, Converter={StaticResource physicianToTextConverter}}" />
                            </StackPanel>
                        </DataTemplate>
                    </custom:AutoCompleteComboBox.ItemTemplate>
                </custom:AutoCompleteComboBox>
                <TextBlock Text="เลือกวันที่ :" VerticalAlignment="Center" Margin="5" />
                <custom:ThaiDatePicker x:Name="PostponeScheduleDatePicker" SelectedDate="{Binding Mode=TwoWay, Path=SelectedPostponeDate}" VerticalAlignment="Center" FirstDayOfWeek="Monday" />
                <TextBlock Text="เวลา :" VerticalAlignment="Center" Margin="5" />
                <TextBox Text="{Binding Mode=TwoWay, Path=SelectedPostponeTime}" Width="50" Height="25"/>
                <TextBlock Text="น." VerticalAlignment="Center" Margin="5" />
            </StackPanel>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                <Button Content="เลื่อนนัด" Width="80" Command="{Binding PostponeCommand}" Style="{StaticResource ButtonStyle}" Cursor="Hand" Margin="5" />
                <Button Content="ยกเลิกนัด" Width="80" Style="{StaticResource ButtonStyle}" Cursor="Hand" Margin="5" Command="{Binding Path=DeleteCommand}" />
            </StackPanel>
        </StackPanel>
    </Grid>
</UserControl>
